//package com.douqu.game.auth.platform;
//
//import com.alibaba.fastjson.JSONObject;
//import com.bean.core.util.HttpStringUtil;
//import com.bean.core.util.TwoTuple;
//import com.douqu.game.auth.database.model.RoleRecordModel;
//import com.douqu.game.auth.service.PlayerService;
//import com.douqu.game.core.database.model.UserModel;
//import com.douqu.game.core.e.ReturnMessage;
//import com.douqu.game.core.factory.PlatformFactory;
//import com.douqu.game.core.protobuf.SGCommonProto;
//import com.douqu.game.core.util.CoreUtils;
//import com.douqu.game.core.util.LogUtils;
//import com.douqu.game.core.util.StringUtils;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Component;
//
//import java.text.MessageFormat;
//
///**
// * Created by Administrator on 2018/9/10 0010.
// */
//@Component
//public class QWImpl implements PlatformSDK {
//
//    @Autowired
//    private PlayerService playerService;
//
//    @Override
//    public TwoTuple<RoleRecordModel, ReturnMessage> auth(int serverId, String account, String password, String deviceId) {
//        LogUtils.info("抢玩登录参数:" + account + "  " + password);
//        String url = MessageFormat.format(PlatformFactory.QW_CHECK_LOGIN_URL, account, password);
//        LogUtils.info("抢玩url:" + url );
//        String str = HttpStringUtil.sendHttpGet(url);
//        LogUtils.info("抢玩str:" + str );
//        JSONObject result = JSONObject.parseObject(str);
//        int status;
//        String msg;
//        try {
//            status =  result.getInteger("status");
//            msg = result.getString("msg");
//            LogUtils.info("抢玩返回值:" + status + "  " + msg);
//        }catch (Exception e){
//            LogUtils.error("WQ获取数据失败:" + account);
//            e.printStackTrace();
//            return new TwoTuple<>(null, ReturnMessage.AUTH_FAILURE);
//        }
//        if( StringUtils.isNullOrEmpty(msg))
//        {
//            LogUtils.error("WQ获取数据失败:" + account);
//            return new TwoTuple<>(null, ReturnMessage.AUTH_FAILURE);
//        }
//        if(status == 0||msg.equals("failed")){
//            LogUtils.error("WQ验证失败:" + account);
//            return new TwoTuple<>(null, ReturnMessage.AUTH_FAILURE);
//        }
//        try {
//            account = CoreUtils.createAccount(account, SGCommonProto.E_CHANNEL_TYPE.CHANNEL_TYPE_QIANGWAN);
//            RoleRecordModel record = playerService.getUserRecordByAccount(account);
//            if(record == null)
//            {//需要创建
//                record = new RoleRecordModel();
//                record.setAccount(account);
//                record.setChannel(SGCommonProto.E_CHANNEL_TYPE.CHANNEL_TYPE_QIANGWAN_VALUE);
//                record.setServerId(serverId);
//                LogUtils.info("抢玩平台第一次登录，创建用户");
//            }
//            return new TwoTuple<>(record, null);
//        } catch (Exception e) {
//            e.printStackTrace();
//            return new TwoTuple<>(null, ReturnMessage.AUTH_FAILURE);
//    }
//
//    }
//}
